<div class="wrapper">
    <div>
        <div class="box box-top">
            <!-- /.box-header -->
            <!-- form start -->
            <form id="discountForm" role="form" action="${base}/admin/discount/save" method="post">
                <input type="hidden" name="id" value="${(discount.id)!}">
                <input type="hidden" value="${(discount.departmentId)!}" class="form-control" name="departmentId"
                       id="departmentId">
                <div class="box-body">
                    <div class="form-group">
                        <label for="departmentId">区域Id</label>
                        <input type="text" disabled value="${(discount.department.name)!}" class="form-control">
                    </div>
                    <div class="form-group">
                        <label for="catagory">类型</label>
                        <select name="catagory" id="catagory" class="form-control">
                            <option value="1" <#if ((discount.catagory)!'1')=='1'> selected="selected"</#if>>----金额优惠券----</option>
                            <option value="2" <#if ((discount.catagory)!'1')=='2'> selected="selected"</#if>>----时长优惠劵----</option>
                        <!--<option value="2" <#if ((discount.catagory)!'1')=='2'> selected="selected"</#if>>&#45;&#45;&#45;&#45;整车租赁&#45;&#45;&#45;&#45;</option>-->
                    </select>
                </div>
                    <div class="form-group">
                        <label for="name">Name</label>
                        <input type="text" value="${(discount.name)!}" class="form-control" name="name" id="name">
                    </div>

                    <div class="form-group">
                        <label for="code">Code</label>
                        <input type="text" value="${(discount.code)!}" class="form-control" name="code" id="code">
                    </div>

                    <div class="form-group">
                        <label for="value">金额或时长(时长单位位：天)</label>
                        <input type="text" value="${(discount.value)!}" class="form-control" name="value" id="value">
                    </div>

                    <div class="form-group">
                        <label for="remark">Note</label>
                        <input type="text" value="${(discount.remark)!}" class="form-control" name="remark" id="remark">
                    </div>

                    <div class="form-group">
                        <label for="firstValid">首次能用</label>
                        <select name="firstValid" id="firstValid" class="form-control">
                            <option value="true" <#if ((discount.firstValid)!true)==true> selected="selected" </#if>>----能用----</option>
                            <option value="false" <#if ((discount.firstValid)!true)==false> selected="selected" </#if>>----Invalid----</option>
                        </select>
                    </div>
                    <div class="form-group">
                        <label for="valid">Valid</label>
                        <select name="valid" id="valid" class="form-control">
                            <option value="true" <#if ((discount.valid)!true)==true> selected="selected" </#if>>----Valid----</option>
                            <option value="false" <#if ((discount.valid)!true)==false> selected="selected" </#if>>----Invalid----</option>
                        </select>
                    </div>

                    <div class="box-footer">
                        <button type="button" onclick="$('#discountForm').submit();" class="btn btn-primary">Save
                        </button>
                    </div>
        </div>
        </form>
    </div>
</div>
</div>
<script type="text/javascript">
    $(function () {
        $("#discountForm").validate({
            submitHandler: function (form) {
                submitDiscount();
            }
        });
    });

    function submitDiscount() {
        HF.ajaxFormSubmit('discountForm', function (result) {
            alert("Save Success");
            document.location.reload();
        }, function (e) {
            alert("Save Failure");
        });
    }
</script>
